// TestParseSql.cpp : Defines the entry point for the console application.
//

#include "stdafx.h"
#include <iostream>
#include "parsesql.h"

int _tmain(int argc, _TCHAR* argv[])
{
	try
	{
		IAZSQL::ParseSQL parse(L"SELECT FirstName AS Name, LastName, MiddleName FROM People WHERE ID=$ID GROUP BY Name,LastName,MiddleName");

		std::wcout << L"List of columns name:" << std::endl;

		IAZSQL::ParseSQL::StringVector columns;
		parse.GetNameColumns(columns);

		std::for_each (columns.cbegin(), columns.cend(), [](const std::wstring& colname)
		{
			std::wcout << colname << L",";
		});
		std::wcout << std::endl;

		parse.AddVariable(L"ID", L"1"); // replace of "$ID" to "1"
		parse.AddCondition(L"AND LastName='Zharkov'"); // added condition

		std::wcout << parse.SQL<std::wstring>() << std::endl;
	}
	catch (IAZSQL::ParseException& ex)
	{
		std::wcout << ex.Message() << std::endl;
	}

	return 0;
}

